using System.Xml.Linq;
using iTextSharp.text;

namespace PocoReport
{
    public class Cell: Text
    {
        public override XNode Save()
        {
            XElement element = new XElement("Cell");
            element.SetAttribValue("Style", Style);
            foreach (IPart part in Parts)
            {
                element.Add(part.Save());
            }
            return element;
        }

        public override IElement GetPdfElement(Document document, Style parentStyle, Scope scope)
        {
            Style mergedStyle = PocoReport.Style.Merge(parentStyle, Style);
            iTextSharp.text.Cell cell = iTextSharp.text.factories.ElementFactory.GetCell(mergedStyle.Properties);
            foreach (IPart part in Parts)
            {
                cell.Add(part.GetPdfElement(document, mergedStyle, scope));
            }
            return cell;
        }
    }
}